package com.nm.orm.dao.impl;

import com.nm.commons.exception.SupperException;
import com.nm.orm.dao.ArticleLabelRefDao;
import com.nm.orm.model.State;
import com.nm.orm.pojo.ArticleLabelRefEntity;
import com.sun.org.apache.regexp.internal.RE;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Administrator on 2017/3/6 0006.
 */
@Repository
@Qualifier("articleLabelRefDao")
public class ArticleLabelRefDaoImpl extends DaoImpl<ArticleLabelRefEntity, String>
        implements ArticleLabelRefDao {

    public ArticleLabelRefDaoImpl() {
        super(ArticleLabelRefEntity.class);
    }

    @Override
    public List<ArticleLabelRefEntity> findAll(String articleId) throws SupperException {

        Criteria criteria = getCurrentSession(sessionFactory).createCriteria(ArticleLabelRefEntity.class);

        criteria.add(Restrictions.eq("this.article.id",articleId));

        List<ArticleLabelRefEntity> alrs = criteria.list();

        return alrs;
    }
}
